package 剑指offer_力扣版.Month07.day06字符串;

import java.util.ArrayList;

public class 最多删除一个字符得到回文 {
    public boolean validPalindrome(String s) {
        int left = 0;
        int right = s.length() - 1;
        while(left <= right){
            if(s.charAt(left) != s.charAt(right)){
                return solve(s,left + 1,right) || solve(s,left,right - 1);
            }
            left++;
            right--;
        }
        return true;
    }

    public boolean solve(String s,int left,int right){
        while(left <= right){
            if(s.charAt(left) != s.charAt(right)){
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
